package com.bblocks.common.anti_reptile.util;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

/**
 * <p>Project: bb-anti-reptile - StrUtil</p>
 * <p>描述：</p>
 *
 * @Author Zhao [125043150@qq.com]
 * @Date 2024/4/3 15:51
 * @Version 1.0
 * @since 8
 */
public class StrUtil {

    /**
     * base64编码
     * @param s
     * @return
     */
    public static String base64Encode(String s) {
        return base64Encode(s.getBytes(StandardCharsets.UTF_8));
    }

    public static String base64Encode(byte[] src) {
        return Base64.getEncoder().encodeToString(src);
    }

    public static void main(String[] args) {
        System.out.println(base64Encode("123"));

        System.out.println(base64Encode("A"));

        System.out.println(base64Encode("ABCDEFGabcdefg"));

        System.out.println(base64Encode("ABCDEFGabcdefg2"));
    }

}
